<template>
  <Navbar
    :left-show="false"
    :title="active === 0 ? '答题' : '跳转'"
    style="font-size: 20px"
  ></Navbar>
  <div class="background">
    <RouterView />
  </div>
  <Tabbar v-model:visible="active" :bottom="true">
    <TabbarItem tab-title="答题" to="/normal"></TabbarItem>
    <TabbarItem tab-title="跳转" to="/step"></TabbarItem>
  </Tabbar>
</template>

<script setup lang="ts">
import { ref, watch } from 'vue';
import { RouterView, useRoute } from 'vue-router';
import { Tabbar, TabbarItem, Navbar } from '@nutui/nutui';

const active = ref(1);

const route = useRoute();
watch(
  () => route.fullPath,
  newPath => {
    if (newPath === '/normal') {
      active.value = 0;
    } else {
      active.value = 1;
    }
  },
);
</script>

<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

.background {
  box-sizing: border-box;
  border-radius: 10px;
  text-align: left;
  margin: 25px;
  padding: 15px;
  background-color: white;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.15);
}

body {
  margin: 0;
  padding: 0;
  background-color: #fafafa;
}
</style>
